package xhhx.manager;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import io.netty.channel.Channel;
import xhhx.akka.GateActor;
import xhhx.network.C2sMsg;


public class ActorManager {
    private final static ActorSystem system = ActorSystem.create("ActorManager");
    private static ActorRef gateRef;

    public static ActorSystem GetSystem() {
        return system;
    }

    public static void Init() {
        gateRef = system.actorOf(GateActor.props());
    }

    public static void Close() {
        system.terminate();
    }


    public static void RemoveLink(Channel ch) {
        gateRef.tell(new GateActor.RemoveMsg(ch), ActorRef.noSender());
    }

    public static void DealWith(Channel ch, C2sMsg msg) {
        gateRef.tell(new GateActor.Msg(ch, msg), ActorRef.noSender());
    }

    public static void AddLink(Channel ch) {
        gateRef.tell(new GateActor.AddMsg(ch), ActorRef.noSender());
    }
}
